package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Daily;
import cn.wolfcode.trip.base.query.DailyQuery;
import cn.wolfcode.trip.base.service.IDailyService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 日报资源控制器
 */
@RestController
@RequestMapping("dailys")
public class DailyController {
    @Autowired
    private IDailyService dailyService;

    @GetMapping("/{id}")
    public Daily getById(@PathVariable Long id){
        Daily daily = dailyService.getById(id);
        return daily;
    }

    @GetMapping("headlines")
    public PageInfo listCommends(DailyQuery qo){
        //按照创建时间倒序
        qo.setOrderBy("createTime desc");
        return dailyService.query(qo);
    }
    @GetMapping("enable")
    public PageInfo list(DailyQuery qo){
        //按照创建时间倒序
        qo.setStateId(1);
        qo.setOrderBy("createTime desc");
        return dailyService.query(qo);
    }
}
